#ifndef __SERVERPROTOCOLACTION_H__
#define __SERVERPROTOCOLACTION_H__

#include "common/chat.h"
#include "common/status.h"
#include <QList>

enum ActionType {
	TConnection = 1,
	TChat = 2,
	TUser = 3,
	TFriend = 4,
};

enum ConnectionFunction {
	CFConnect = 1,
	CFDisconnect = 2,
	CFAnswerKeepAlive = 4,
};

enum ChatFunction {
	HFStart = 1,
	HFInvite = 2,
	HFSend = 3,
	HFExit = 4,
};

enum UserFunction {
	UFPassword = 3,
	UFStatus = 4,
	UFSignup = 5,
};

enum FriendFunction {
	FFInvite = 1,
	FFAccept = 2,
	FFDeny = 3,
	FFRemove = 5,
};

class ServerProtocolAction {
public:
	virtual ActionType getType() = 0;
	QString getIp();
	quint16 getPort();
	void setIp(QString _ip);
	void setPort(quint16 _port);
private:
	QString ip;
	quint16 port;
};

class ServerConnectionAction: public ServerProtocolAction {
public:
	ServerConnectionAction(ConnectionFunction function, QString login = "", QString password = "");
	ActionType getType();
	ConnectionFunction getFunction();
	QString getLogin();
	QString getPassword();
private:
	ConnectionFunction function;
	QString login;
	QString password;
};

class ServerChatAction: public ServerProtocolAction {
public:
	ServerChatAction(ChatFunction function, int id);
	ServerChatAction(ChatFunction function, Chat* chat, int id);
	ServerChatAction(ChatFunction function, Chat* chat, QString message);
	ServerChatAction(ChatFunction function, Chat* chat);
	ActionType getType();
	ChatFunction getFunction();
	int getId();
	QString getMessage();
	Chat* getChat();
private:
	ChatFunction function;
	Chat* chat;
	int id;
	QString message;
};

class ServerUserAction: public ServerProtocolAction {
public:
	ServerUserAction(UserFunction function, QString string1, QString string2);
	ServerUserAction(UserFunction function, Status newStatus);
	ActionType getType();
	UserFunction getFunction();
	QString getOldPassword();
	QString getNewPassword();
	QString getLogin();
	QString getPassword();
	Status getNewStatus();
private:
	UserFunction function;
	QString string1;
	QString string2;
	Status newStatus;
};

class ServerFriendAction: public ServerProtocolAction {
public:
	ServerFriendAction(FriendFunction function, QString friendLogin);
	ServerFriendAction(FriendFunction function, Friend* f);
	ActionType getType();
	FriendFunction getFunction();
	QString getLogin();
	Friend* getFriend();
private:
	FriendFunction function;
	QString login;
	Friend* f;
};

#endif
